//
//  WDAutoSize.m
//  OralRobot
//
//  Created by superwu_work on 16/6/8.
//  Copyright © 2016年 wangguimin. All rights reserved.
//

#import "WDAutoSize.h"

@implementation WDAutoSize

+(CGFloat)getHeightwithFont:(NSInteger)fontSize withText:(NSString *)text withWidth:(CGFloat)width {
    NSDictionary *dic = @{NSFontAttributeName:font(fontSize)};
    //    通过字典计算高度和宽度
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

+(CGFloat)getWidthtwithFont:(NSInteger)fontSize withText:(NSString *)text withHeight:(CGFloat)height {
    NSDictionary *dic = @{NSFontAttributeName:font(fontSize)};
    //    通过字典计算高度和宽度
    CGRect rect = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.width;

}



@end
